<template>
    <input />
    <button @click="click">发送</button>
    <button @click="close">关闭</button>
</template>
<script lang="ts" setup>
    const ws = new WebSocket("ws://localhost:3001")
    ws.onopen = function(e)
    {
        console.log("connect...");
    }

    ws.onmessage = function(e)
    {
        console.log("send message");
    }

    // ws.onclose = function()
    // {
    //     console.log("close connect!");
    // }

    // ws.onerror = function()
    // {
    //     console.log("socket error...");
    // }

    const click =()=>{
        ws.send("send message...");
    }

    const close =()=>{
        ws.close();
    }

</script>
<style scoped>
</style>